<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    //async 函数返回一个 Promise 对象，可以使用 then 方法添加回调函数。
    async function hello() {
        return 'hello'
    }
    // let promise = hello();
    // console.log(promise);
    // promise.then((res) => {
    //     console.log(res);
    // })

    function testAwait(data) {
        return new Promise((success, reject) => {
            setTimeout(() => {
                success(data + '123');
            }, 3000)
        })
    }

    async function fn() {
        var x = await testAwait("hello");
        console.log(x);
        console.log("fn--------");
    }
    fn();
</script>

</html>